//app.js
var util = require('/database/data.js');
App({
  globalData: {
    smsbaoApi: "https://www.smsbao.com",
    mapApi: "https://api.map.baidu.com",
    unionApi: "https://union.smsbao.com",
    appId: "add4cfdde51a4ce48120d0fcb02b8c93",
    appKey: "c8a0bfa2d00e4561b8c9b62ef3be0707",
  },
  onLaunch: function(e) {   
    var order = wx.getStorageSync('order');
    this.clearStorage('order', order)
    var more = wx.getStorageSync('more');
    this.clearStorage('more', more)
  },
  clearStorage: function(key, data) {
    var data_len = data.length;
    if (data_len > 100) {
      data.shift();
    }
    wx.setStorageSync(key, data);
  },

  //封装请求函数
  post: function (url, data, method, header) {
    var promise = new Promise((resolve, reject) => {
      var that = this;
      //网络请求
      wx.request({
        url: url,
        data: data,
        method: method,
        header: header,
        complete: function (res) {
          resolve(res)
        }
      })
    });
    return promise;
  },

})